﻿Imports EguSoc_Dll

Public Class FES_GestionSobre
    Private TA_CabecerasSobres As New Cabecera_SobreTableAdapter
    Private _Permisos As Integer

    Private Sub BtnEjecutar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnEjecutar.Click
        Try
            Cargar_Datos()
        Catch ex As Exception

        End Try
    End Sub

    Private Sub TSBExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TSBExit.Click
        Try
            Me.Close()
        Catch ex As Exception

        End Try

    End Sub

    Private Sub Cargar_Datos()
        Try
            Select Case _Permisos
                Case 3
                    TA_CabecerasSobres.FillByTipoSobreFechas(DSEA.Cabecera_Sobre, "P", DTPDesde.Value, DTPHasta.Value)
                Case 4
                    TA_CabecerasSobres.FillByAdministradorSobre(DSEA.Cabecera_Sobre, DTPDesde.Value, DTPHasta.Value)
            End Select
        Catch ex As Exception

        End Try

    End Sub

    Private Sub FES_GestionSobre_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Try
            DTPDesde.Value = DateAdd(DateInterval.Month, -1, Now)
        Catch ex As Exception

        End Try
    End Sub

    Public Sub New(ByVal Permisos As Integer)
        ' Llamada necesaria para el diseñador.
        InitializeComponent()

        ' Agregue cualquier inicialización después de la llamada a InitializeComponent().
        _Permisos = Permisos
    End Sub

    Private Sub SociosBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TSBSaveItem.Click
        Try
            TA_CabecerasSobres.Repaso_Administracion(DSEA.Cabecera_Sobre)
            Cabecera_SobreBindingSource.EndEdit()
            TA_CabecerasSobres.Guardar(DSEA.Cabecera_Sobre)

            Me.Cargar_Datos()
        Catch ex As Exception

        End Try
    End Sub

    Private Sub Cabecera_SobreDataGridView_CellContentClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles Cabecera_SobreDataGridView.CellContentClick
        Try

            If e.ColumnIndex = Me.Cabecera_SobreDataGridView.Columns.Item("Aceptar").Index Then
                Dim chkCell As DataGridViewCheckBoxCell = Me.Cabecera_SobreDataGridView.Rows(e.RowIndex).Cells("Aceptar")
                Dim chkCell2 As DataGridViewCheckBoxCell = Me.Cabecera_SobreDataGridView.Rows(e.RowIndex).Cells("Rechazar")
                chkCell.Value = Not chkCell.Value
                If chkCell.Value Then
                    chkCell2.Value = False
                Else
                    chkCell2.Value = True
                End If
            ElseIf e.ColumnIndex = Me.Cabecera_SobreDataGridView.Columns.Item("Rechazar").Index Then
                Dim chkCell As DataGridViewCheckBoxCell = Me.Cabecera_SobreDataGridView.Rows(e.RowIndex).Cells("Rechazar")
                Dim chkCell2 As DataGridViewCheckBoxCell = Me.Cabecera_SobreDataGridView.Rows(e.RowIndex).Cells("Aceptar")
                chkCell.Value = Not chkCell.Value
                If chkCell.Value Then
                    chkCell2.Value = False
                Else
                    chkCell2.Value = True
                End If
            End If

            Me.Cabecera_SobreDataGridView.Refresh()
        Catch ex As Exception

        End Try
    End Sub
End Class